package com.vgulu.server.common.exception;

import com.vgulu.server.common.bean.VResponse;

/**
 * Created by wangchunsee on 16/2/17.
 */
public class VBaseException extends RuntimeException {
    public static final String TAG="VBaseException";

    //通用错误码
    public static final int SERVER_ERROR = 1000;
    public static final int PARAM_ERROR = 2000;

    public static final VBaseException InvalidParam =new VBaseException(PARAM_ERROR,"无效参数");
    public static final VBaseException UnloginParam =new VBaseException(PARAM_ERROR+1,"未登录");
    public static final VBaseException UploadFormatSupport = new VBaseException(PARAM_ERROR+2,"上传格式不支持");
    public static final VBaseException EmailExistException =new VBaseException(PARAM_ERROR+3,"此Email已注册,请直接登录");
    public static final VBaseException NotRegisterException =new VBaseException(PARAM_ERROR+4,"用户未注册");
    public static final VBaseException PasswordErrorException =new VBaseException(PARAM_ERROR+5,"密码错误");
    public static final VBaseException MobileExistException = new VBaseException(PARAM_ERROR+6,"此手机已被注册,请直接登录");
    public static final VBaseException MobileNotRegisterException = new VBaseException(PARAM_ERROR+7,"此手机未注册");
    public static final VBaseException MobileHadSet=new VBaseException(PARAM_ERROR+7,"手机曾经已设置,如果忘记密码,请重置密码");
    public static final VBaseException SmsCodeError=new VBaseException(PARAM_ERROR+8,"验证码错误");
    public static final VBaseException SmsCodeSceneError=new VBaseException(PARAM_ERROR+9,"验证码场景错误");
    public static final VBaseException SmsCodeExpired=new VBaseException(PARAM_ERROR+10,"验证码已失效,请重新获取");
    public static final VBaseException AuthResourceNotExist=new VBaseException(PARAM_ERROR+11,"资源不存在");
    public static final VBaseException AuthResCtrlIsExist=new VBaseException(PARAM_ERROR+12,"该组已在资源管理队列中");
    public static final VBaseException NoAuth = new VBaseException(PARAM_ERROR+13,"用户没有权限");


    public static final VBaseException ServiceException =new VBaseException(SERVER_ERROR,"服务器内部异常");
    public static final VBaseException CreateUidFailed=new VBaseException(SERVER_ERROR+1,"创建用户UID失败");
    public static final VBaseException TokenCheckFailed = new VBaseException(SERVER_ERROR+2,"校验Token失败");

    private int code;

    public VBaseException(){
        super();
    }

    public VBaseException(Throwable e){
        super(e);
        code=SERVER_ERROR;
    }


    public VBaseException(int code,String msg){
        super(msg);
        this.code=code;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

}
